package com.wholesale.beans;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Order {
	private String address;
	private String addTime;
	private String bestTime;
	private double bonus;
	private int bonusId;
	private double cardFee;
	private int cardId;
	private String cardMessage;
	private String cardName;
	private int city;
	private String confirmTime;
	private String consignee;
	private int country;
	private String currency;
	// private List<whoOrderGoods> daoOrderGoodsList ;
	private double discount;
	private int district;
	private String extensionCode;
	private int extensionId;
	private double goodsAmount;
	private List<GoodsInOrder> goodsList;
	private int goodsNumber;
	private double insureFee;
	private int integral;
	private double integralMoney;
	private String invContent;
	private String invoiceNo;
	private String invPayee;
	private String invType;
	private String mobile;
	private double moneyPaid;
	private double orderAmount;
	private int orderId;
	private String orderSn;
	private int orderStatus;
	private double packFee;
	private int packId;
	private String packName;
	private double payFee;
	private int payId;
	private String payName;
	private String payNote;
	private int payStatus;
	private String payTime;
	private String postscript;
	private int province;
	private double rate;
	private String referer;
	private double shippingFee;
	private int shippingId;
	private String shippingName;
	private int shippingStatus;
	private String shippingTime;
	private String signBuilding;
	private double surplus;
	private double tax;
	private String tel;
	private String toBuyer;
	private int userId;
	private String zipcode;
	private JSONObject jsonObject;

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getAddTime() {
		return addTime;
	}

	public void setAddTime(String addTime) {
		this.addTime = addTime;
	}

	public String getBestTime() {
		return bestTime;
	}

	public void setBestTime(String bestTime) {
		this.bestTime = bestTime;
	}

	public double getBonus() {
		return bonus;
	}

	public void setBonus(double bonus) {
		this.bonus = bonus;
	}

	public int getBonusId() {
		return bonusId;
	}

	public void setBonusId(int bonusId) {
		this.bonusId = bonusId;
	}

	public double getCardFee() {
		return cardFee;
	}

	public void setCardFee(double cardFee) {
		this.cardFee = cardFee;
	}

	public int getCardId() {
		return cardId;
	}

	public void setCardId(int cardId) {
		this.cardId = cardId;
	}

	public String getCardMessage() {
		return cardMessage;
	}

	public void setCardMessage(String cardMessage) {
		this.cardMessage = cardMessage;
	}

	public String getCardName() {
		return cardName;
	}

	public void setCardName(String cardName) {
		this.cardName = cardName;
	}

	public int getCity() {
		return city;
	}

	public void setCity(int city) {
		this.city = city;
	}

	public String getConfirmTime() {
		return confirmTime;
	}

	public void setConfirmTime(String confirmTime) {
		this.confirmTime = confirmTime;
	}

	public String getConsignee() {
		return consignee;
	}

	public void setConsignee(String consignee) {
		this.consignee = consignee;
	}

	public int getCountry() {
		return country;
	}

	public void setCountry(int country) {
		this.country = country;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public int getDistrict() {
		return district;
	}

	public void setDistrict(int district) {
		this.district = district;
	}

	public String getExtensionCode() {
		return extensionCode;
	}

	public void setExtensionCode(String extensionCode) {
		this.extensionCode = extensionCode;
	}

	public int getExtensionId() {
		return extensionId;
	}

	public void setExtensionId(int extensionId) {
		this.extensionId = extensionId;
	}

	public double getGoodsAmount() {
		return goodsAmount;
	}

	public void setGoodsAmount(double goodsAmount) {
		this.goodsAmount = goodsAmount;
	}

	public List<GoodsInOrder> getGoodsList() {

		return goodsList;
	}

	public void setGoodsList(ArrayList<GoodsInOrder> goodsList) {
		this.goodsList = goodsList;
	}

	public int getGoodsNumber() {
		return goodsNumber;
	}

	public void setGoodsNumber(int goodsNumber) {
		this.goodsNumber = goodsNumber;
	}

	public double getInsureFee() {
		return insureFee;
	}

	public void setInsureFee(double insureFee) {
		this.insureFee = insureFee;
	}

	public int getIntegral() {
		return integral;
	}

	public void setIntegral(int integral) {
		this.integral = integral;
	}

	public double getIntegralMoney() {

		return integralMoney;
	}

	public void setIntegralMoney(double integralMoney) {
		this.integralMoney = integralMoney;
	}

	public String getInvContent() {
		return invContent;
	}

	public void setInvContent(String invContent) {
		this.invContent = invContent;
	}

	public String getInvoiceNo() {
		return invoiceNo;
	}

	public void setInvoiceNo(String invoiceNo) {
		this.invoiceNo = invoiceNo;
	}

	public String getInvPayee() {
		return invPayee;
	}

	public void setInvPayee(String invPayee) {
		this.invPayee = invPayee;
	}

	public String getInvType() {
		return invType;
	}

	public void setInvType(String invType) {
		this.invType = invType;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public double getMoneyPaid() {
		return moneyPaid;
	}

	public void setMoneyPaid(double moneyPaid) {
		this.moneyPaid = moneyPaid;
	}

	public double getOrderAmount() {
		return orderAmount;
	}

	public void setOrderAmount(double orderAmount) {
		this.orderAmount = orderAmount;
	}

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public String getOrderSn() {
		return orderSn;
	}

	public void setOrderSn(String orderSn) {
		this.orderSn = orderSn;
	}

	public int getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(int orderStatus) {
		this.orderStatus = orderStatus;
	}

	public double getPackFee() {
		return packFee;
	}

	public void setPackFee(double packFee) {
		this.packFee = packFee;
	}

	public int getPackId() {
		return packId;
	}

	public void setPackId(int packId) {
		this.packId = packId;
	}

	public String getPackName() {
		return packName;
	}

	public void setPackName(String packName) {
		this.packName = packName;
	}

	public double getPayFee() {
		return payFee;
	}

	public void setPayFee(double payFee) {
		this.payFee = payFee;
	}

	public int getPayId() {
		return payId;
	}

	public void setPayId(int payId) {
		this.payId = payId;
	}

	public String getPayName() {
		return payName;
	}

	public void setPayName(String payName) {
		this.payName = payName;
	}

	public String getPayNote() {
		return payNote;
	}

	public void setPayNote(String payNote) {
		this.payNote = payNote;
	}

	public int getPayStatus() {
		return payStatus;
	}

	public void setPayStatus(int payStatus) {
		this.payStatus = payStatus;
	}

	public String getPayTime() {
		return payTime;
	}

	public void setPayTime(String payTime) {
		this.payTime = payTime;
	}

	public String getPostscript() {
		return postscript;
	}

	public void setPostscript(String postscript) {
		this.postscript = postscript;
	}

	public int getProvince() {
		return province;
	}

	public void setProvince(int province) {
		this.province = province;
	}

	public double getRate() {
		return rate;
	}

	public void setRate(double rate) {
		this.rate = rate;
	}

	public String getReferer() {
		return referer;
	}

	public void setReferer(String referer) {
		this.referer = referer;
	}

	public double getShippingFee() {
		return shippingFee;
	}

	public void setShippingFee(double shippingFee) {
		this.shippingFee = shippingFee;
	}

	public int getShippingId() {
		return shippingId;
	}

	public void setShippingId(int shippingId) {
		this.shippingId = shippingId;
	}

	public String getShippingName() {
		return shippingName;
	}

	public void setShippingName(String shippingName) {
		this.shippingName = shippingName;
	}

	public int getShippingStatus() {
		return shippingStatus;
	}

	public void setShippingStatus(int shippingStatus) {
		this.shippingStatus = shippingStatus;
	}

	public String getShippingTime() {
		return shippingTime;
	}

	public void setShippingTime(String shippingTime) {
		this.shippingTime = shippingTime;
	}

	public String getSignBuilding() {
		return signBuilding;
	}

	public void setSignBuilding(String signBuilding) {
		this.signBuilding = signBuilding;
	}

	public double getSurplus() {
		return surplus;
	}

	public void setSurplus(double surplus) {
		this.surplus = surplus;
	}

	public double getTax() {

		return tax;
	}

	public void setTax(double tax) {
		this.tax = tax;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getToBuyer() {
		return toBuyer;
	}

	public void setToBuyer(String toBuyer) {
		this.toBuyer = toBuyer;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipCode(String zipcode) {
		this.zipcode = zipcode;
	}

	public String getShippingStatusName() {
		if (shippingStatus == 0) {
			return "Unshipped";
		} else if (shippingStatus == 1) {
			return "Shipped";
		} else if (shippingStatus == 2) {
			return "Has been receiving";
		} else if (shippingStatus == 3) {
			return "Stocking in";
		} else if (shippingStatus == 4) {
			return "Rreturn of goods";
		} else {
			return "Unknown";
		}
	}

	public String getPayStatusName() {
		if (payStatus == 0) {
			return "Unpaid";
		} else if (payStatus == 1) {
			return "Paying";
		} else if (payStatus == 2) {
			return "Paid";
		} else {
			return "Unknown";
		}
	}

	public String getOrderStatusName() {
		if (orderStatus == 0) {
			return "Unrecognized";
		} else if (orderStatus == 1) {
			return "Recognized";
		} else if (orderStatus == 2) {
			return "Canceled";
		} else if (orderStatus == 3) {
			return "Invalid";
		} else if (orderStatus == 4) {
			return "Rreturn of goods";
		} else {
			return "Unknown";
		}
	}

	/**
	 * 
	 * @param type
	 *            0.新增 1.修改 2.删除 如果是删除，实体中只需要order的id即可
	 * @return
	 */
	public String toJsonString(int type) {
		JSONObject jsonObject = new JSONObject();
		try {
			if (type == 0) {
				jsonObject.put("orderSn", orderSn);
				jsonObject.put("userId", userId);
				jsonObject.put("orderStatus", orderStatus);
				jsonObject.put("shippingStatus", shippingStatus);
				jsonObject.put("payStatus", payStatus);
				jsonObject.put("consignee", consignee);
				jsonObject.put("country", country);
				jsonObject.put("province", province);
				jsonObject.put("city", city);
				jsonObject.put("district", district);
				jsonObject.put("address", address);
				jsonObject.put("zipcode", zipcode);
				jsonObject.put("tel", tel);
				jsonObject.put("mobile", mobile);
				jsonObject.put("shippingId", shippingId);
				jsonObject.put("shippingName", shippingName);
				jsonObject.put("payId", payId);
				jsonObject.put("payName", payName);
				jsonObject.put("goodsAmount", goodsAmount);
				jsonObject.put("shippingFee", shippingFee);
				jsonObject.put("insureFee", insureFee);
				jsonObject.put("payFee", payFee);
				jsonObject.put("surplus", surplus);
				jsonObject.put("orderAmount", orderAmount);
				if (goodsList != null && goodsList.size() > 0) {
					JSONArray jsonArray = new JSONArray();
					for (GoodsInOrder goodsInOrder : goodsList) {
						jsonArray.put(goodsInOrder.getJSONObject());
					}
					jsonObject.put("goodsList", jsonArray);
				}
			} else if (type == 2) {
				jsonObject.put("orderId", orderId);
			} else {
				jsonObject.put("orderId", orderId);
				jsonObject.put("orderSn", orderSn);
				jsonObject.put("userId", userId);
				jsonObject.put("orderStatus", orderStatus);
				jsonObject.put("shippingStatus", shippingStatus);
				jsonObject.put("payStatus", payStatus);
				jsonObject.put("consignee", consignee);
				jsonObject.put("country", country);
				jsonObject.put("province", province);
				jsonObject.put("city", city);
				jsonObject.put("district", district);
				jsonObject.put("address", address);
				jsonObject.put("zipcode", zipcode);
				jsonObject.put("tel", tel);
				jsonObject.put("mobile", mobile);
				jsonObject.put("bestTime", bestTime);
				jsonObject.put("signBuilding", signBuilding);
				jsonObject.put("postscript", postscript);
				jsonObject.put("shippingId", shippingId);
				jsonObject.put("shippingName", shippingName);
				jsonObject.put("payId", payId);
				jsonObject.put("payName", payName);
				jsonObject.put("packName", packName);
				jsonObject.put("cardName", cardName);
				jsonObject.put("cardMessage", cardMessage);
				jsonObject.put("invPayee", invPayee);
				jsonObject.put("invContent", invContent);
				jsonObject.put("goodsAmount", goodsAmount);
				jsonObject.put("shippingFee", shippingFee);
				jsonObject.put("insureFee", insureFee);
				jsonObject.put("payFee", payFee);
				jsonObject.put("packFee", packFee);
				jsonObject.put("cardFee", cardFee);
				jsonObject.put("moneyPaid", moneyPaid);
				jsonObject.put("surplus", surplus);
				jsonObject.put("integral", integral);
				jsonObject.put("integralMoney", integralMoney);
				jsonObject.put("bonus", bonus);
				jsonObject.put("orderAmount", orderAmount);
				jsonObject.put("referer", referer);
				if (addTime != null) {
					jsonObject.put("addTime", addTime);
				}
				if (confirmTime != null) {
					jsonObject.put("confirmTime", confirmTime);
				}
				if (payTime != null) {
					jsonObject.put("payTime", payTime);
				}
				if (shippingTime != null) {
					jsonObject.put("shippingTime", shippingTime);
				}
				jsonObject.put("packId", packId);
				jsonObject.put("cardId", cardId);
				jsonObject.put("bonusId", bonusId);
				jsonObject.put("invoiceNo", invoiceNo);
				jsonObject.put("extensionCode", extensionCode);
				jsonObject.put("extensionId", extensionId);
				jsonObject.put("extensionCode", extensionCode);
				jsonObject.put("toBuyer", toBuyer);
				jsonObject.put("payNote", payNote);
				jsonObject.put("invType", invType);
				jsonObject.put("tax", tax);
				jsonObject.put("discount", discount);
				jsonObject.put("goodsNumber", goodsNumber);
				jsonObject.put("currency", currency);
				jsonObject.put("rate", rate);
				if (goodsList != null && goodsList.size() > 0) {
					JSONArray jsonArray = new JSONArray();
					for (GoodsInOrder goodsInOrder : goodsList) {
						jsonArray.put(goodsInOrder.getJSONObject());
					}
					jsonObject.put("goodsList", jsonArray);
				}
			}
		} catch (Exception e) {
		}
		return jsonObject.toString();
	}

	public void jsonAnalytic(String jsonString) {

		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {

		}
	}

	public void jsonAnalytic(JSONObject jsonObject) {
		this.jsonObject = jsonObject;

		try {
			orderId = jsonObject.getInt("orderId");
		} catch (JSONException e) {

		}
		try {
			orderSn = jsonObject.getString("orderSn");
		} catch (JSONException e) {

		}
		try {
			userId = jsonObject.getInt("userId");
		} catch (JSONException e) {

		}
		try {
			orderStatus = jsonObject.getInt("orderStatus");
		} catch (JSONException e) {

		}
		try {
			shippingStatus = jsonObject.getInt("shippingStatus");
		} catch (JSONException e1) {
			e1.printStackTrace();
		}
		try {
			payStatus = jsonObject.getInt("payStatus");
		} catch (JSONException e) {

		}
		try {
			consignee = jsonObject.getString("consignee");
		} catch (JSONException e) {

		}
		try {
			country = jsonObject.getInt("country");
		} catch (JSONException e) {

		}
		try {
			province = jsonObject.getInt("province");
		} catch (JSONException e1) {
			e1.printStackTrace();
		}
		try {
			city = jsonObject.getInt("city");
		} catch (JSONException e) {

		}
		try {
			district = jsonObject.getInt("district");
		} catch (JSONException e) {

		}
		try {
			address = jsonObject.getString("address");
		} catch (JSONException e) {

		}
		try {
			zipcode = jsonObject.getString("zipcode");
		} catch (JSONException e) {

		}
		try {
			tel = jsonObject.getString("tel");
		} catch (JSONException e) {

		}
		try {
			mobile = jsonObject.getString("mobile");
		} catch (JSONException e) {

		}
		try {
			bestTime = jsonObject.getString("bestTime");
		} catch (JSONException e) {

		}
		try {
			signBuilding = jsonObject.getString("signBuilding");
		} catch (JSONException e) {

		}
		try {
			postscript = jsonObject.getString("postscript");
		} catch (JSONException e) {

		}
		try {
			shippingId = jsonObject.getInt("shippingId");
		} catch (JSONException e) {

		}
		try {
			shippingName = jsonObject.getString("shippingName");
		} catch (JSONException e) {

		}
		try {
			payId = jsonObject.getInt("payId");
		} catch (JSONException e) {

		}
		try {
			payName = jsonObject.getString("payName");
		} catch (JSONException e) {

		}
		try {
			packName = jsonObject.getString("packName");
		} catch (JSONException e) {

		}
		try {
			cardName = jsonObject.getString("cardName");
		} catch (JSONException e) {

		}
		try {
			cardMessage = jsonObject.getString("cardMessage");
		} catch (JSONException e) {

		}
		try {
			invPayee = jsonObject.getString("invPayee");
		} catch (JSONException e) {

		}
		try {
			invContent = jsonObject.getString("invContent");
		} catch (JSONException e) {

		}
		try {
			goodsAmount = jsonObject.getDouble("goodsAmount");
		} catch (JSONException e) {

		}
		try {
			shippingFee = jsonObject.getDouble("shippingFee");
		} catch (JSONException e) {

		}
		try {
			insureFee = jsonObject.getDouble("insureFee");
		} catch (JSONException e) {

		}
		try {
			payFee = jsonObject.getDouble("payFee");
		} catch (JSONException e) {

		}
		try {
			packFee = jsonObject.getDouble("packFee");
		} catch (JSONException e) {

		}
		try {
			cardFee = jsonObject.getDouble("cardFee");
		} catch (JSONException e) {

		}
		try {
			moneyPaid = jsonObject.getDouble("moneyPaid");
		} catch (JSONException e) {

		}
		try {
			surplus = jsonObject.getDouble("surplus");
		} catch (JSONException e) {

		}
		try {
			integral = jsonObject.getInt("integral");
		} catch (JSONException e) {

		}
		try {
			integralMoney = jsonObject.getDouble("integralMoney");
		} catch (JSONException e) {

		}
		try {
			bonus = jsonObject.getDouble("bonus");
		} catch (JSONException e) {

		}
		try {
			orderAmount = jsonObject.getDouble("orderAmount");
		} catch (JSONException e) {

		}
		try {
			referer = jsonObject.getString("referer");
		} catch (JSONException e) {

		}
		try {
			addTime = jsonObject.getString("addTime");
		} catch (JSONException e) {

		}
		try {
			confirmTime = jsonObject.getString("confirmTime");
		} catch (JSONException e) {

		}
		try {
			payTime = jsonObject.getString("payTime");
		} catch (JSONException e) {

		}
		try {
			shippingTime = jsonObject.getString("shippingTime");
		} catch (JSONException e) {

		}
		try {
			packId = jsonObject.getInt("packId");
		} catch (JSONException e) {

		}
		try {
			cardId = jsonObject.getInt("cardId");
		} catch (JSONException e) {

		}
		try {
			bonusId = jsonObject.getInt("bonusId");
		} catch (JSONException e) {

		}
		try {
			invoiceNo = jsonObject.getString("invoiceNo");
		} catch (JSONException e) {

		}
		try {
			extensionCode = jsonObject.getString("extensionCode");
		} catch (JSONException e) {

		}
		try {
			extensionId = jsonObject.getInt("extensionId");
		} catch (JSONException e) {

		}
		try {
			extensionCode = jsonObject.getString("extensionCode");
		} catch (JSONException e) {

		}
		try {
			toBuyer = jsonObject.getString("toBuyer");
		} catch (JSONException e) {

		}
		try {
			payNote = jsonObject.getString("payNote");
		} catch (JSONException e) {

		}
		try {
			invType = jsonObject.getString("invType");
		} catch (JSONException e) {

		}
		try {
			tax = jsonObject.getDouble("tax");
		} catch (JSONException e1) {
			e1.printStackTrace();
		}
		try {
			discount = jsonObject.getDouble("discount");
		} catch (JSONException e) {

		}
		try {
			goodsNumber = jsonObject.getInt("goodsNumber");
		} catch (JSONException e) {

		}
		try {
			currency = jsonObject.getString("currency");
		} catch (JSONException e) {

		}
		try {
			rate = jsonObject.getDouble("rate");
		} catch (JSONException e) {

		}

	}
}
